﻿using System.Web;
using Wedn.Web.Handler;

namespace Wedn.Web.UI.Admin.Handler
{
    /// <summary>
    /// 加载外链CSS文件
    /// </summary>
    public class LoadStyles : IHttpHandler
    {
        public void ProcessRequest(HttpContext context)
        {
            //context.Response.ContentType = "text/css";
            //string dir = context.Request.QueryString["dir"];
            //string[] styles = context.Request.QueryString["load"].Split(',');
            //string pathFormat = "/admin/resource/css/{0}.css";
            //HttpHandler.LoadResource(context, styles, pathFormat);
            context.Response.ContentType = "text/css";
            string load = context.Request.QueryString["load"];
            if (load == null)
                context.Response.End();
            string dir = context.Request.QueryString["dir"] ?? "css";
            //string dir = "/admin/resource/" + (rDir == null ? "css" : rDir);
            string[] styles = load.Split(',');
            string pathFormat = "/admin/resource/" + dir + "/{0}.css";
            HttpHandler.LoadResource(context, styles, pathFormat);
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}